<template>
	<view class="container">
		<view class="header" :style="{ paddingTop: statusBarHeight + 'px' }">
			<text class="title">设置</text>
		</view>

		<!-- 个人信息卡片 -->
		<view class="user-card">
			<view class="avatar-wrapper">
				<image class="avatar" src="/static/images/user.jpg" mode="aspectFill"></image>
			</view>
			<view class="user-info">
				<text class="username">Fiewroks</text>
				<text class="user-id">ID: 12345678</text>
			</view>
		</view>

		<!-- 设置列表 -->
		<view class="settings-list">
			<view class="settings-group">
				<view class="settings-item">
					<view class="item-left">
						<text class="item-icon">🔒</text>
						<text class="item-label">账号与安全</text>
					</view>
					<text class="item-arrow">›</text>
				</view>
				<view class="settings-item">
					<view class="item-left">
						<text class="item-icon">🔔</text>
						<text class="item-label">通知设置</text>
					</view>
					<text class="item-arrow">›</text>
				</view>
				<view class="settings-item" @click="goToPrivacy()">
					<view class="item-left">
						<text class="item-icon">👁️</text>
						<text class="item-label">隐私政策</text>
					</view>
					<text class="item-arrow">›</text>
				</view>
				<view class="settings-item">
					<view class="item-left">
						<text class="item-icon">ℹ️</text>
						<text class="item-label">关于我们</text>
					</view>
					<text class="item-arrow">›</text>
				</view>
			</view>

			<button class="logout-btn" @click="handleLogout">退出登录</button>
		</view>
	</view>
</template>

<script>
import { mapActions } from 'vuex'

export default {
	data() {
		return {
			statusBarHeight: 0
		}
	},
	onLoad() {
		this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
	},
	methods: {
		...mapActions(['logout']),
		handleLogout() {
			uni.showModal({
				title: '提示',
				content: '确定要退出登录吗？',
				success: (res) => {
					if (res.confirm) {
						this.logout()
					}
				}
			})
		},
		goToPrivacy() {
			uni.navigateTo({
				url: '/pages/privacy/privacy'
			})
		}
	}
}
</script>

<style>
.container {
	min-height: 100vh;
	background: #f5f5f5;
}

.header {
	background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
	padding: 20rpx 40rpx 120rpx;
}

.title {
	color: #fff;
	font-size: 36rpx;
	font-weight: 500;
}

.user-card {
	margin: -80rpx 40rpx 0;
	background: #fff;
	border-radius: 20rpx;
	padding: 40rpx;
	display: flex;
	align-items: center;
	box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
}

.avatar-wrapper {
	width: 120rpx;
	height: 120rpx;
	border-radius: 60rpx;
	overflow: hidden;
	border: 4rpx solid rgba(99, 102, 241, 0.1);
	margin-right: 30rpx;
}

.avatar {
	width: 100%;
	height: 100%;
}

.user-info {
	flex: 1;
}

.username {
	font-size: 36rpx;
	color: #333;
	font-weight: 500;
	margin-bottom: 8rpx;
	margin-right: 30rpx;
}

.user-id {
	font-size: 24rpx;
	color: #999;
}

.settings-list {
	margin: 30rpx 40rpx;
}

.settings-group {
	background: #fff;
	border-radius: 20rpx;
	overflow: hidden;
	margin-bottom: 40rpx;
}

.settings-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 30rpx;
	border-bottom: 1rpx solid #f5f5f5;
}

.settings-item:last-child {
	border-bottom: none;
}

.item-left {
	display: flex;
	align-items: center;
}

.item-icon {
	font-size: 40rpx;
	margin-right: 20rpx;
}

.item-label {
	font-size: 28rpx;
	color: #333;
}

.item-arrow {
	color: #999;
	font-size: 36rpx;
}

.logout-btn {
	width: 100%;
	height: 88rpx;
	line-height: 88rpx;
	background: #fff;
	border-radius: 44rpx;
	color: #f43f5e;
	font-size: 32rpx;
	border: none;
}

.logout-btn::after {
	border: none;
}
</style>